package cate.game.activity.merge.msg;

import cate.common.table.d.GDFunc;
import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.activity.serverprogress.ServerProgressActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBMergeAct;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "合服活动-全服目标-领奖 请求")
public class MergeServerProgressGetRewardReq implements MsgInput {
    @NoteField("配置ID")
    public int tid;

    @Override
    public MsgConfig conf() {
        return MsgIdBMergeAct.MERGE_ACT_SERVER_PROGRESS_GET_REWARD_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        ServerProgressActivity activity = cc.getRole().getActivity().getEnableActivitySingle(GDFunc.MergeAct.MERGE_ACT_SERVER_TARGET);
        if (activity == null) {
            game.notice.message(cc.getRole(), "合服目标活动未开启");
            return;
        }
        GameResult<Void> r = activity.onGetProgressReward(tid);
        if (r.ok()) {
            activity.initSend();
        }
        game.notice.message(cc.getRole(), r, true);
    }
}
